﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using FlightSystemWCF;

namespace FlightSystemWCFHost
{
    public partial class FlightService : ServiceBase
    {
        internal static ServiceHost flightSystemServiceHost = null; 

        public FlightService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            if (flightSystemServiceHost != null)
            {
                flightSystemServiceHost.Close();
            }
            flightSystemServiceHost = new ServiceHost(typeof(FlightSystemService));
            flightSystemServiceHost.Open();
        }

        protected override void OnStop()
        {
            if (flightSystemServiceHost != null)
            {
                flightSystemServiceHost.Close();
                flightSystemServiceHost = null;
            }
        }
    }
}
